$(function(){
	$('#taskCode').focus();
    taskFormValid();
    //保存验证
    $("#subBtn").on('click',function () {
        submitForm();
    })
    var taskTime=new Date();
    laydate.render({
		elem:'#b_taskHs',
		type:'time',
        format: 'HH:mm:ss',
		value: taskTime,
		zIndex: 99
	})
})
function taskFormValid() {
    $("#taskForm").validate({
        rules: {
            b_taskCode: {
                required: true,
                minlength: 3,
            },
            b_taskName: {
                required: true,
                minlength: 3,
            },
            b_taskHs:{
                required: true,
                minlength: 6,
            },
            b_iotTable:{
                required: true,
                minlength: 6,
            },
            b_taskPeriod:{
                digits:true
            },
            b_taskExpect:{
                digits:true
            },
            b_rowSort: {
                required: true,
                minlength: 1,
                isPositiveInteger: true
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        errorElement: "span",
        errorClass: "errorDevice",
        success: 'valid',
        messages: {
            b_taskCode: {
                required: " (必填)",
                minlength: " (不能少于3个字母)",
            },
            b_taskName: {
                required: " (必填)",
                minlength: " (不能少于 3 个字母)",
            },
            b_taskHs:{
                required: " (必填)",
                minlength: " (不能3个字母)"
            },
            b_iotTable:{
                required: " (必填)",
                minlength: " (不能3个字母)"
            },
            b_taskPeriod:{
                digits:"输入正整数"
            },
            b_taskExpect:{
                digits:"输入正整数"
            },
            b_rowSort:{
                isDigits: "输入正整数"
            }
        },
    });
}

function submitForm() {
    if($('#taskForm').valid()){
        return false;
    }
    return {};
}
